package cn.dengta.webapp.user.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import cn.dengta.webapp.user.model.ActStatus;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@TableName("act_user_halloween")
public class ActUserHalloween extends TimeBasedEntity {

	/** 周期 */
	private Date period;
	/** 用户id */
	private Long userId;
	/** 登录状态 1=已领取；0=未领取；-1=未完成 */
	private ActStatus login;
	/** 收到万圣节礼物状态  1=已领取；0=未领取；-1=未完成 */
	private ActStatus getGift;
	/** 发送万圣节礼物状态  1=已领取；0=未领取；-1=未完成 */
	private ActStatus sendGift;
	/** 发送万圣节动态 状态  1=已领取；0=未领取；-1=未完成 */
	private ActStatus dynamic;
	/** 充值一笔  1=已领取；0=未领取；-1=未完成 */
	private ActStatus recharge;

	public static final String USER_ID = "user_id";
	public static final String LOGIN = "login";
	public static final String GET_GIFT = "get_gift";
	public static final String SEND_GIFT = "send_gift";
	public static final String DYNAMIC = "dynamic";
	public static final String RECHARGE = "recharge";

	/** 默认数据 */
	public static ActUserHalloween ofDefault() {
		ActUserHalloween uh = new ActUserHalloween();
		uh.setLogin(ActStatus.un_finished);
		uh.setGetGift(ActStatus.un_finished);
		uh.setSendGift(ActStatus.un_finished);
		uh.setDynamic(ActStatus.un_finished);
		uh.setRecharge(ActStatus.un_finished);
		return uh;
	}

	public static ActUserHalloween of(Long id, String field, ActStatus actStatus) {
		ActUserHalloween halloween = new ActUserHalloween();
		halloween.setId(id);
		halloween.switchField(field, actStatus);
		return halloween;
	}

	public void switchField(String field, ActStatus actStatus) {
		switch (field) {
			case LOGIN:
				this.setLogin(actStatus);
				break;
			case GET_GIFT:
				this.setGetGift(actStatus);
				break;
			case SEND_GIFT:
				this.setSendGift(actStatus);
				break;
			case DYNAMIC:
				this.setDynamic(actStatus);
				break;
			case RECHARGE:
				this.setRecharge(actStatus);
				break;
		}
	}

	public boolean isUnComplete(String field) {
		switch (field) {
			case LOGIN:
				return this.login == ActStatus.un_finished;
			case GET_GIFT:
				return this.getGift == ActStatus.un_finished;
			case SEND_GIFT:
				return this.sendGift == ActStatus.un_finished;
			case DYNAMIC:
				return this.dynamic == ActStatus.un_finished;
			case RECHARGE:
				return this.recharge == ActStatus.un_finished;
		}
		return false;
	}

	/** 获取任务状态*/
	public Integer getTaskStatus(Long taskId){
		Integer status = null;
		switch (taskId + "") {
			case "1":
				status = this.getLogin().getValue();
				if (ActStatus.un_finished.getValue().equals(status)){
					status = ActStatus.un_get.getValue();
				}
				break;
			case "2":
				status = this.getGetGift().getValue();
				break;
			case "3":
				status = this.getSendGift().getValue();
				break;
			case "4":
				status = this.getDynamic().getValue();
				break;
			case "5":
				status = this.getRecharge().getValue();
		}

		return status;
	}

	/** 获取任务*/
	public static String getTastFiled(Long taskId){
		String status = null;
		switch (taskId + "") {
			case "1":
				status = ActUserHalloween.LOGIN;
				break;
			case "2":
				status = ActUserHalloween.GET_GIFT;
				break;
			case "3":
				status = ActUserHalloween.SEND_GIFT;
				break;
			case "4":
				status = ActUserHalloween.DYNAMIC;
				break;
			case "5":
				status = ActUserHalloween.RECHARGE;
		}

		return status;
	}

}
